package shoppingmall.manage.mapper;

import org.apache.ibatis.annotations.*;
import shoppingmall.manage.pojo.CommodityCategory;

import java.util.List;

/**
 * 商品分类相关
 */
@Mapper
public interface CommodityCategoryMapper {

    /**
     * 查询商品分类总条数
     * @return
     */
    @Select("select count(*) from tb_commodity_category")
    public int getCommodityCategoryCount ();

    /**
     * 分页查询商品分类记录
     * @param start
     * @param pageSize
     * @return
     */
    @Select("select * from tb_commodity_category limit #{start},#{pageSize}")
    public List<CommodityCategory> getCommodityCategoryList (int start, int pageSize);

    /**
     * ***查询所有的商品分类信息(接口查询商品信息是给响应数据商品分类id 替换成 商品分类名称 需要用到)
     */
    public List<CommodityCategory> getAllCommodityCategoryList ();

    /**
     * 添加一条商品分类记录
     */
    @Insert("insert into tb_commodity_category (category_name) values (#{categoryName})")
    public void saveCommodityCategory (String categoryName);

    /**
     * 修改一条商品分类记录
     */
    public void updateCommodityCategory (CommodityCategory commodityCategory);

    /**
     * 删除一条商品分类记录
     */
    @Delete("delete from tb_commodity_category where category_id = #{categoryId} ")
    public void deleteCommodityCategory (int categoryId);

    /**
     * 批量删除商品分类记录 categoryIds
     */
    public int deleteCommodityCategoryBatch (List<Integer> categoryIds);
}
